package com.shinhye.mobilelottery.utils;

import java.io.InputStream;
import java.util.Properties;

public class BeanFactory {
	private static Properties props;
	
	static {
		props = new Properties();
		InputStream is = BeanFactory.class.getClassLoader().getResourceAsStream("bean.properties");
		try {
			props.load(is);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static <T> T getImpl(Class<T> clazz) {
		String cla = clazz.getSimpleName();
		String engine = props.getProperty(cla);
		T instance = null;
		try {
			instance = (T) Class.forName(engine).newInstance();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return instance;
	}
}
